;(function() {
		'use strict';
		angular.module('services.resource.resourceUseRate',[])
			.factory('resourceUseRateService', resourceUseRateService);

		function resourceUseRateService(Restangular,odOperationDevelop) {
			return {
				queryNetworkDevice : function(params,callback){
					Restangular.all('sas/OMdisplay/usageRate/networkFailwall').post(params).then(callback);
				},
				queryNetworkRouter : function(params,callback){
					Restangular.all('sas/OMdisplay/usageRate/networkRouter').post(params).then(callback);
				},
				queryNetworkExchangeMachine : function(params,callback){
					Restangular.all('sas/OMdisplay/usageRate/networkExchangeMachine').post(params).then(callback);
				},
				changeGrid : function(option){
					option.grid ={
						x2:110
					};
				},
				getData : function(res,time,title){
					var echartsTitle = time+title;
					var title1 = echartsTitle+'对CPU的使用率';
					var title2 = echartsTitle+'对流量的使用情况';
					var title3 = echartsTitle+'对内存的使用率';
					var title4 = echartsTitle+'温度';
					var myEcharts = echarts.init(document.getElementById('doc'));
					var myEcharts1 = echarts.init(document.getElementById('doc1'));
					var myEcharts2 = echarts.init(document.getElementById('doc2'));
					var myEcharts3 = echarts.init(document.getElementById('doc3'));
					var a = odOperationDevelop.getEchartsData(res.data.cpu,title1,'time','hostIp','rate','line');
					var b = odOperationDevelop.getEchartsData(res.data.gprs,title2,'time','hostIp','rate','line');
					var c = odOperationDevelop.getEchartsData(res.data.ram,title3,'time','hostIp','rate','line');
					var d = odOperationDevelop.getEchartsData(res.data.temperature,title4,'time','hostIp','rate','line');
					this.changeGrid(a);
					this.changeGrid(b);
					this.changeGrid(c);
					this.changeGrid(d);
					myEcharts.setOption(a);
					myEcharts1.setOption(b);
					myEcharts2.setOption(c);
					myEcharts3.setOption(d);
				},
				getTimeType : function(){
					return [{
						timeTypeCode: '0',
						timeTypeName: '时'
					}, {
						timeTypeCode: '1',
						timeTypeName: '日'
					}];
				},
				getRegion : function(){
					return [
						{regionCode:'1',regionName:'前置'},
						{regionCode:'2',regionName:'核心'},
						{regionCode:'3',regionName:'后置'}
					];
				},
				getNetWorkEquipment : function(){
					return [
						{resourceCode:'1',resourceName:'防火墙'},
						{resourceCode:'2',resourceName:'路由器'},
						{resourceCode:'3',resourceName:'交换机'},
						{resourceCode:'4',resourceName:'负载均衡器'}
					];
				},
				getPageBind : function(){
					return {
						system:'11',
						region:[],
						resource:[],
						timeType:'1'
					};
				}
			};
		}
})();